package com.xhwl.data.service.impl;


import com.xhwl.common.pojo.cent.sdata.SdataAccountQuickDataBoard;
import com.xhwl.common.utils.ChkUtil;
import com.xhwl.data.dao.SdataAccountQuickDataBoardDao;
import com.xhwl.data.pojo.AccountBoardRoleDTO;
import com.xhwl.data.pojo.dto.AccountBoardDTO;
import com.xhwl.data.service.IPermissionDataBoardService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @description:
 * @author:
 * @create: 2020-11-25
 **/
@Service
@Slf4j
public class PermissionDataBoardServiceImpl implements IPermissionDataBoardService {

    @Autowired
    SdataAccountQuickDataBoardDao sdataAccountQuickDataBoardDao;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public SdataAccountQuickDataBoard detail(Integer roleId, Integer projectId) {
        SdataAccountQuickDataBoard res = sdataAccountQuickDataBoardDao.selectLastRecord(roleId, projectId);
        if (ChkUtil.isNull(res)) {
            return new SdataAccountQuickDataBoard();
        }
        return res;
    }

    @Override
    public void save(AccountBoardDTO accountBoardDTO) {
        sdataAccountQuickDataBoardDao.delData(accountBoardDTO);
        sdataAccountQuickDataBoardDao.saveData(accountBoardDTO);
    }

    @Override
    public void saveDataRole(AccountBoardRoleDTO accountBoardRoleDTO) {
        sdataAccountQuickDataBoardDao.delDataRole(accountBoardRoleDTO);
        sdataAccountQuickDataBoardDao.saveDataRole(accountBoardRoleDTO);
    }

    @Override
    public AccountBoardRoleDTO queryDataRole(AccountBoardRoleDTO accountBoardRoleDTO) {
        return sdataAccountQuickDataBoardDao.queryDataRole(accountBoardRoleDTO);
    }
}
